package com.jingxi.portal.controller;

import com.jingxi.portal.pojo.ItemInfo;
import com.jingxi.portal.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ItemCotroller {
    @Autowired
    ItemService itemService;
    @RequestMapping("/item/{itemId}")
    public String showItem(@PathVariable long itemId, Model model){
        ItemInfo item=itemService.getItemById(itemId);
        model.addAttribute("item",item);
        return "item";
    }
    @RequestMapping(value = "/item/desc/{itemId}",produces = MediaType.TEXT_HTML_VALUE+";charset=utf-8")
    public String getItemDescById(@PathVariable long itemId){
        String  item=itemService.getItemDescById(itemId);
        return item;
    }
    @RequestMapping(value = "/item/param/{itemId}",produces = MediaType.TEXT_HTML_VALUE+";charset=utf-8")
    public String getItemParamById(@PathVariable long itemId){
        String  item=itemService.getItemParamById(itemId);
        return item;
    }
}
